<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>xx-ai 文件目录浏览器</title>
    <link th:href="@{/css/bootstrap/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/css/bootstrap/font/bootstrap-icons.css}" rel="stylesheet">
    <link th:href="@{/css/style.css}" rel="stylesheet">
</head>
<body>
    <div class="container-fluid">
        <!-- 导航栏 -->
        <nav class="navbar navbar-expand-lg navbar-dark bg-primary mb-4">
            <div class="container-fluid">
                <a class="navbar-brand" href="#">
                    <i class="bi bi-folder2-open"></i>
                    xx-ai 文件浏览器
                </a>
            </div>
        </nav>

        <!-- 主要内容 -->
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <h5 class="card-title mb-0">
                            <i class="bi bi-house-door"></i>
                            欢迎使用文件目录浏览器
                        </h5>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-8">
                                <h6>选择要浏览的目录</h6>
                                <form action="/file/browse" method="get" class="mb-3">
                                    <div class="input-group">
                                        <span class="input-group-text">
                                            <i class="bi bi-folder"></i>
                                        </span>
                                        <input type="text" 
                                               class="form-control" 
                                               name="path" 
                                               placeholder="请输入目录路径" 
                                               th:value="${defaultPath}"
                                               required>
                                        <button class="btn btn-primary" type="submit">
                                            <i class="bi bi-search"></i>
                                            浏览
                                        </button>
                                    </div>
                                </form>

                                <!-- 快捷目录 -->
                                <div class="row">
                                    <div class="col-12">
                                        <h6>快捷目录</h6>
                                        <div class="d-flex flex-wrap gap-2">
                                            <a th:href="@{/file/browse(path=${defaultPath})}" 
                                               class="btn btn-outline-secondary btn-sm">
                                                <i class="bi bi-house"></i>
                                                用户主目录
                                            </a>
                                            <a th:href="@{/file/browse(path='C:/')}" 
                                               class="btn btn-outline-secondary btn-sm">
                                                <i class="bi bi-hdd"></i>
                                                C: 盘
                                            </a>
                                            <a th:href="@{/file/browse(path='D:/')}" 
                                               class="btn btn-outline-secondary btn-sm">
                                                <i class="bi bi-hdd"></i>
                                                D: 盘
                                            </a>
                                            <a th:href="@{/file/browse(path='E:/')}" 
                                               class="btn btn-outline-secondary btn-sm">
                                                <i class="bi bi-hdd"></i>
                                                E: 盘
                                            </a>
                                            <a th:href="@{/file/upload(path=${defaultPath})}" 
                                               class="btn btn-outline-success btn-sm">
                                                <i class="bi bi-cloud-upload"></i>
                                                文件上传
                                            </a>
                                            <!-- 添加获取IP地址按钮 -->
                                            <button id="showIpAddressesBtn" class="btn btn-outline-info btn-sm">
                                                <i class="bi bi-info-circle"></i>
                                                获取访问地址
                                            </button>
                                        </div>
                                    </div>
                                </div>
                                <div class="row mt-3">
                                    <div class="col-12">
                                        <h6>移动设备访问</h6>
                                        <p>使用手机浏览器扫描下方二维码，可直接访问文件浏览器首页：</p>
                                        <a th:href="@{/file/qrcode}" target="_blank">
                                            <img th:src="@{/file/qrcode}" alt="二维码访问" class="img-fluid" style="max-width: 200px;">
                                        </a>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="card bg-light">
                                    <div class="card-body">
                                        <h6 class="card-title">功能说明</h6>
                                        <ul class="list-unstyled">
                                            <li><i class="bi bi-check-circle text-success"></i> 浏览本地文件和目录</li>
                                            <li><i class="bi bi-check-circle text-success"></i> 目录列表展示</li>
                                            <li><i class="bi bi-check-circle text-success"></i> 文件大小和时间显示</li>
                                            <li><i class="bi bi-check-circle text-success"></i> 支持多种排序方式</li>
                                            <li><i class="bi bi-check-circle text-success"></i> 文件上传下载功能</li>
                                            <li><i class="bi bi-check-circle text-success"></i> 响应式设计</li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 使用说明 -->
        <div class="row mt-4">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <h6 class="card-title mb-0">
                            <i class="bi bi-info-circle"></i>
                            使用说明
                        </h6>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-6">
                                <h6>基本操作</h6>
                                <ul>
                                    <li>在输入框中输入目录路径，点击"浏览"按钮</li>
                                    <li>点击目录名称可以进入该目录</li>
                                    <li>使用面包屑导航可以快速返回上级目录</li>
                                    <li>支持显示/隐藏隐藏文件</li>
                                </ul>
                            </div>
                            <div class="col-md-6">
                                <h6>排序功能</h6>
                                <ul>
                                    <li>按名称排序：文件和目录按字母顺序排列</li>
                                    <li>按大小排序：文件按大小排列（目录始终在前）</li>
                                    <li>按修改时间排序：按最后修改时间排列</li>
                                    <li>支持升序和降序两种排序方向</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- IP地址显示模态框 -->
    <div class="modal fade" id="ipAddressesModal" tabindex="-1" aria-labelledby="ipAddressesModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="ipAddressesModalLabel">
                        <i class="bi bi-info-circle"></i>
                        可访问的地址
                    </h5>
                    <button type="button" class="btn-close" data-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <p>您可以通过以下地址访问本系统：</p>
                    <div id="ipAddressesList">
                        <div class="spinner-border text-primary" role="status">
                            <span class="visually-hidden">加载中...</span>
                        </div>
                        <p class="mt-2">正在获取IP地址信息...</p>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="copyAllAddressesBtn">复制所有地址</button>
                </div>
            </div>
        </div>
    </div>

    <script th:src="@{/js/jquery-3.6.0.min.js}"></script>
    <script th:src="@{/js/bootstrap/bootstrap.bundle.min.js}"></script>
    <script th:src="@{/js/bootstrap/bootstrap.js}"></script>
    <script th:src="@{/js/app.js}"></script>
</body>
</html>